<template>
  <div class="device-info-overview">
    <div class="title">设备统计</div>
    <div class="list">
      <div v-for="(item,index) in device" :key="index" class="item" :class="'item-' + (index + 1)">
        <div class="value">{{ item.value }}</div>
        <div class="name">{{ item.name }}</div>
        <img v-if="index === 0" class="icon" src="../assets/images/zbtj_icon_syj.png">
        <img v-else-if="index === 1" class="icon" src="../assets/images/zbtj_icon_xcplc.png">
        <img v-else class="icon" src="../assets/images/zbtj_icon_tcplc.png">
      </div>
    </div>
    <div class="charts-wrap">
      <div class="charts-box">
        <div class="total-info">
          <div class="value">{{ total }}</div>
          <div class="name">总台数</div>
        </div>
        <device-status-charts :data="data" />
      </div>
      <div class="info-box">
        <div v-for="(item,index) in data" :key="index" class="item">
          <div class="dot" :class="'dot-' + (index + 1)"></div>
          <div class="status">{{ item.name }}</div>
          <div class="value">{{ item.value }}</div>
          <div class="rate">{{ item.ratio }}</div>
        </div>
      </div>
    </div>
    

  </div>
</template>

<script>
import deviceStatusCharts from './device-status-charts'

export default {
  name: 'device-info-overview',
  props: {
    device: {
      type: Array,
      default: () => []
    },
    data: {
      type: Array,
      default: () => []
    },
    total: {
      type: Number,
      default: 0
    }
  },
  components: {
    deviceStatusCharts
  }
}
</script>

<style lang="scss">
.device-info-overview {
  overflow: hidden;
  padding-bottom: 0.16rem;
  .title {
    height: 0.22rem;
    line-height: 0.22rem;
    font-size: 0.18rem;
    color: #00DEFF;
    padding-left: 0.26rem;
    background: url('../assets/images/xbt.png') left center no-repeat;
    background-size: 0.22rem auto;
    margin-bottom: 0.16rem;
    font-weight: bold;
  }
  .list {
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    .item {
      display: flex;
      flex-direction: column;
      align-items: center;
      .value {
        font-size: 0.24rem;
        line-height: 0.28rem;
        font-weight: bold;
      }
      .name {
        font-size: 0.14rem;
        line-height: 0.18rem;
        color: #FFFFFF;
        position: relative;
        z-index: 2;
      }
      .icon {
        width: 0.76rem;
        height: 0.83rem;
        margin-top: -0.36rem;
      }
    }
    .item-1 {
      .value {
        color: #02C46D;
      }
    }
    .item-2 {
      .value {
        color: #00F3FF;
      }
    }
    .item-3 {
      .value {
        color: #F8B62D;
      }
    }
  }
  .charts-wrap {
    height: 1.8rem;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    .charts-box {
      width: 50%;
      height: 100%;
      position: relative;
      .total-info {
        width: 0.68rem;
        height: 0.68rem;
        border-radius: 50%;
        background-color: #141e37;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        border: 1px solid #6C8097;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        line-height: 1.2;
        .value {
          font-size: 0.24rem;
          color: #FFFFFF;
          font-weight: bold;
        }
        .name {
          font-size: 0.12rem;
          color: #6C8097;
        }
      }
    }
    .info-box {
      flex: 1;
      overflow: hidden;
    }
  }
  .info-box {
    .item {
      display: flex;
      align-items: center;
      font-size: 0.16rem;
      color: #fff;
      line-height: 0.2rem;
      margin: 0.16rem 0;
      .dot {
        width: 0.16rem;
        height: 0.16rem;
        margin-right: 0.1rem;
        border-radius: 50%;
      }
      .dot-1 {
        background: linear-gradient(177.19deg, #143BFD 0%, #0A89FF 100%);
      }
      .dot-2 {
        background: linear-gradient(270deg, #1F739F 0%, #023164 100%);
      }
      .status {
        width: 0.52rem;
      }
      .value {
        width: 0.54rem;
      }
      .rate {
        flex: 1;
      }
    }
  }
}
</style>